package bluetooth;

import android.bluetooth.BluetoothAdapter;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;

public class BluetoothUt {
	private Context mContext;
	private final int REQUEST_ENABLE_BT=1;
	public BluetoothUt(Context context){
		this.mContext=context;
	}
	public boolean checkBluetoothAvailability(){
		BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
		if (mBluetoothAdapter == null) {
		    Toast.makeText(mContext, "This device does not support Bluetooth communication!", Toast.LENGTH_SHORT).show();
		    return false;
		}
		else{
			return true;

		}
	}
	public void enableBluetooth(){
		if (this.checkBluetoothAvailability()){
			BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
			if (!mBluetoothAdapter.isEnabled()) {
			    Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
			    mContext.startActivity(enableBtIntent);
			}
			else{
			    //Toast.makeText(mContext, "Open!", Toast.LENGTH_SHORT).show();
			}
			
		}
		
	}
}
